package com.atguigu.srb.oss.controller.api;

import com.atguigu.srb.common.result.R;
import com.atguigu.srb.oss.service.ApiOssService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import javax.annotation.Resource;

@RestController

@RequestMapping("/api/oss/file")
@Api(tags = "文件存储服务")
public class ApiOssController {
    @Resource
    private ApiOssService apiOssService;
    @PostMapping("/upload")
    @ApiOperation("文件上传系统")
    public R upload(@RequestParam("module") String module, @RequestParam("file") MultipartFile multipartFile){
        String url = apiOssService.upload(module, multipartFile);
        return R.ok().data("url",url);

    }
    @DeleteMapping("/remove")
    @ApiOperation("文件删除系统")
    public R remove(@RequestParam("url") String url){
        boolean b =apiOssService .remove(url);
        return R.ok();
    }
}
